
$(document).ready(function() {
  var myClassAttr = $("#page").attr("class");
  debug(myClassAttr);
  /* Load js dynamically
  var $page_id = $('#page')
  var headID = document.getElementsByTagName("head")[0];
  var newScript = document.createElement('script');
  newScript.type = 'text/javascript';
  newScript.src = 'js/lib.js';
  headID.appendChild(newScript);
  */

  // --- Create ARIA attributes
  aria.initRoles();

  // --- Concatenate IE6 class
  //if ($.browser.msie && $.browser.version=="6.0") {
    multiClass.init('div.box,div.axs');
  //}

  // --- Equal Heights
  equalHeight($(".column"));
	
});

/**
 * IE6 don't understand CSS multiclasses (ex: .simple.classic{color: #000;}) 
 * Concatenate 2 CSS classes preceded by trigger class "elem" and pattern is [trigger][type][skin-style]
 */
var multiClass = {
    init: function(trig) {
		  if ($(trig).length) {
		    var $box = $(trig);
		    for (var i = 0, len = $box.length; i < len; i++) {
		      var class_attributes = $($box[i]).attr("class").split(" ");
		      // --- Le pattern est de 3 classes CSS
		      if (class_attributes.length > 2) {
		        for (var j = 0, len2 = class_attributes.length; j < len2; j++) {
		          if (typeof(class_attributes[j+1]) != "undefined" && typeof(class_attributes[j+2]) != "undefined") {
		            // --- Concatenate classes
		            $($box[i]).addClass(class_attributes[j+1] + '-' + class_attributes[j+2]);
		            debug(class_attributes[j+1] + '-' + class_attributes[j+2]);
		          }
		        }
		      }
		    }
		  }
	  }
};

/**
 * Prevent and Facilitate debugging
 */
function debug(elem) {
  if (window['loadFirebugConsole']) {
    console.log(elem);
  }
}

if (typeof(console) === 'undefined') {
  var console = {}
  console.log = console.error = console.info = console.debug = console.warn = console.trace = console.dir = console.dirxml = console.group = console.groupEnd = console.time = console.timeEnd = console.assert = console.profile = function() {};
}

/**
 * Init Aria attributes
 */
var aria = {
    initRoles: function() {
      $('.navigation').attr('role','navigation');
      $('#main').attr('role','main');
      $('#logo').attr('role','banner');
      $('#footer').attr('role','contentinfo');
	  }
};


function equalHeight(bloc) {
  var tallest = 0;
  for (var i = 0,len = bloc.length; i < len; i++) {
  	var thisHeight = $(bloc[i]).height();
  	if (thisHeight > tallest) {
  		tallest = thisHeight;
  	}
  }
  bloc.height(tallest);
}
